09 尚品甄选-后台系统-商品和订单管理
1 商品管理
商品管理就是对电商项目中所涉及到的商品数据进行维护。
1.1 菜单添加
首先在系统中添加商品管理的菜单,具体步骤如下所示:
1、在后台管理系统中通过系统管理的菜单管理添加商品管理的相关菜单,如下所示:

2、给系统管理员角色分配商品商品管理菜单访问权限:

3、在前端项目中创建对应的页面,以及配置对应的异步路由
- 在src/views/product的文件夹中加入商品管理页面文件product.vue, 如下所示:

- 在src/router/modules文件夹下创建product.js路由文件,文件内容如下所示:
const Layout = () => import('@/layout/index.vue')
const category = () => import('@/views/product/category.vue')
const brand = () => import('@/views/product/brand.vue')
const categoryBrand = () => import('@/views/product/categoryBrand.vue')
const productSpec = () => import('@/views/product/productSpec.vue')
const product = () => import('@/views/product/product.vue')
export default [
{
path: '/product',
component: Layout,
name: 'product',
meta: {
title: '商品管理',
},
icon: 'Histogram',
children: [
{
path: '/category',
name: 'category',
component: category,
meta: {
title: '分类管理',
},
},
{
path: '/brand',
name: 'brand',
component: brand,
meta: {
title: '品牌管理',
},
},
{
path: '/categoryBrand',
name: 'categoryBrand',
component: categoryBrand,
meta: {
title: '分类品牌',
},
},
{
path: '/productSpec',
name: 'productSpec',
component: productSpec,
meta: {
title: '商品规格',
},
},
{
path: '/product',
name: 'product',
component: product,
meta: {
title: '商品管理',
},
},
],
},
]
1.2 表结构介绍
商品数据所对应的表结构如下所示:
CREATE TABLE `product` (
`id` bigint NOT NULL AUTO_INCREMENT COMMENT 'ID',
`name` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8_general_ci DEFAULT NULL COMMENT '商品名称',
`brand_id` bigint DEFAULT NULL COMMENT '品牌ID',
`category1_id` bigint DEFAULT NULL COMMENT '一级分类id',
`category2_id` bigint DEFAULT NULL COMMENT '二级分类id',
`category3_id` bigint DEFAULT NULL COMMENT '三级分类id',
`unit_name` varchar(50) CHARACTER SET utf8mb3 COLLATE utf8_general_ci DEFAULT NULL COMMENT '计量单位',
`slider_urls` text COMMENT '轮播图',
`spec_value` varchar(255) DEFAULT NULL COMMENT '商品规格json',
`status` tinyint NOT NULL DEFAULT '0' COMMENT '线上状态:0-初始值,1-上架,-1-自主下架',
`audit_status` tinyint NOT NULL DEFAULT '0' COMMENT '审核状态:0-初始值,1-通过,-1-未通过',
`audit_message` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8_general_ci DEFAULT NULL COMMENT '审核信息',
`create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
`is_deleted` tinyint NOT NULL DEFAULT '0' COMMENT '删除标记(0:不可用 1:可用)',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='商品';